package com.szu.smart_illustrator.rest;

import com.szu.smart_illustrator.common.R;
import com.szu.smart_illustrator.dto.param.passage.*;
import com.szu.smart_illustrator.entity.Passage;
import com.szu.smart_illustrator.service.PassageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 文章相关接口
 * @author 冼铧城
 * @date 2023/11/23
 */
@RestController
@RequestMapping("Passage")
public class PassageController {


    @Autowired
    PassageService passageService;

    /**
     * 搜索所有文章
     *
     * @param dto
     * @return {@link R}<{@link List}<{@link Passage}>>
     */
    @PostMapping("SearchPassages")
        public R<List<Passage>> SearchPassages(@RequestBody SearchPassagesParamDto dto){
         return  passageService.SearchPassages(dto);
    }


    /**
     * 添加文章
     *
     * @param dto
     * @return {@link R}<{@link Passage}>
     */
    @PostMapping("AddPassage")
    public R<Passage> addPassage(@RequestBody AddPassageParamDto dto){
     return  passageService.addPassage(dto);
}


    /**
     * 保存文章
     * @param dto
     * @return {@link R}<{@link String}>
     */
    @PostMapping("SavePassage")
    public R<String> savePassage(@RequestBody SavePassageParamDto dto){
     return  passageService.savePassage(dto);
}

    /**
     * 获取文章通过id
     *
     * @param dto
     * @return {@link R}<{@link Passage}>
     */
    @PostMapping("GetPassageById")
       public R<Passage> getPassageById(@RequestBody GetPassageByIdParamDto dto){
        return passageService.getPassageById(dto);
   }

    /**
     * delete文章
     *
     * @param dto
     * @return {@link R}<{@link String}>
     */
    @PostMapping("DeletePassage")
       public R<String> deletePassage(@RequestBody DeletePassageParamDto dto){
        return passageService.deletePassage(dto);
   }



}
